#特殊方法和运算符重载

# class Person:
#     def __init__(self,name):
#         self.name=name
#
#     def __add__(self, other):
#         if isinstance(other,Person):
#             return "{0}--{1}".format(self.name,other.name)
#         else:
#             return "不是同类，不能相加"
#
#     def __mul__(self, other):
#         if isinstance(other,int):
#             return self.name*other
#         else:
#             return "不是同类对象，不能相乘"
#
# p1 = Person("zhangfei")
# p2 = Person("zhangbao")
# x=p1+p2
#
# print(x)
# print(x*2)
# print(p1*5)
#浅拷贝深拷贝
import copy


class MobilePhone:
    def __init__(self,cpu,screen):
        self.cpu=cpu
        self.screen=screen

class CPU:
    def calculate(self):
        print("计算计算")
        print("cpu对象",self)
class Screen:
    def show(self):
        print("显示一个好看的画面")
        print("screen对象".self)

c1=CPU()
c2=c1
print(c1)
print(c2)
#测试浅复制
print("测试浅复制")
s1=Screen()
m1=MobilePhone(c1,s1)
m2=copy.copy(m1)
print(m1,m1.cpu,m1.screen)
print(m2,m2.cpu,m2.screen)
print("测试深复制")
#测试深复制
m3=copy.deepcopy(m1)
print(m1,m1.cpu,m1.screen)
print(m3,m3.cpu,m3.screen)



